package game.logic.app;

import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.themes.FlatMacDarkLaf;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;

public class AppLauncher
{
    public static void main(String[] args) throws IOException
    {
        BufferedImage icon = ImageIO.read(AppLauncher.class.getResource("/component.png"));

        FlatMacDarkLaf.setup();

        CompletableFuture.runAsync(() -> Solutions.load(new File("solutions_kv.txt")));

        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame("逻辑拼图");
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.setIconImage(icon);

            GameBoard board = new GameBoard();
            frame.getRootPane().putClientProperty(FlatClientProperties.FULL_WINDOW_CONTENT, true);
            frame.getContentPane().add(board);
            frame.pack();

            board.requestFocus();

            frame.setLocationRelativeTo(null);
            frame.setResizable(false);
            frame.setVisible(true);
        });
    }
}
